# -------------------------------------------------------------------
# CMakeLists.txt
# cmake build file
#
# Created by Daniil Smelov on July 15, 2010
# Copyright (C) 2010 Daniil Smelov All rights reserved
# -------------------------------------------------------------------

cmake_minimum_required(VERSION 2.6)

# Including our custom Android-specific definitions (like compiler and
# compiler options
include(android.cmake)
add_definitions( -DHAVE_CONFIG_H -D_REENTRANT -DUSE_MEMORY_H -DANDROID
-D__SGI_STL_INTERNAL_PAIR_H -DANDROID -DOS_ANDROID  -DTARGET_OS=android 
-DOSNAME=android -DBUILD_OSNAME=android -D_ARM_ASSEM_ -DFICL_ANSI=1 -DEZXML_NOMMAP=1 
-DUNDER_ANDROID -DUL_ANDROID -DDISABLE_THREADS -DDISABLE_AUDIO -DDISABLE_VIDEO 
-DDISABLE_EVENTS -DDISABLE_JOYSTICK -DDISABLE_CDROM -DDISABLE_TIMERS)


# BUILD_ONE_LIBRARY variable is used in every library's subdirectory. If it is
# defined then a static library (.a on *NIX, .lib on WIN32), is being built in
# every subdirectory
SET(BUILD_ONE_LIBRARY true)
SET(LIBRARY_NAME ozex)


SET(INCLUDE_DIRS ./core
./libs/cross/libgeotrans/src 
./libs/cross/ezxml 
./libs/cross/sdlgfx 
./libs/cross/ul 
./libs/cross/sdl/include
./libs/cross/sdl/src
./libs/cross/sdlimage
./libs/cross/sdl/src/events
./libs/cross/sdl/src/video
./libs/cross/sdl/src/thread
./libs/cross/sdl/src/thread/generic
./libs/cross/sdl/src/timer
./libs/cross/sdl/src/joystick
)

include_directories(${INCLUDE_DIRS})

# So, we're about to build one library to rule them all and in the ozex bind
# them. 
add_library(${LIBRARY_NAME} SHARED jniwrappers.cpp 
	armeabifn.c 
	libs/cross/sdl/src/video/SDL_surface.c 
	libs/cross/sdl/src/SDL_error.c 
	libs/cross/sdl/src/video/SDL_RLEaccel.c 
	libs/cross/sdl/src/video/SDL_pixels.c 
	libs/cross/sdl/src/video/SDL_blit.c 
	libs/cross/sdl/src/video/SDL_blit_0.c
	libs/cross/sdl/src/video/SDL_blit_1.c
	libs/cross/sdl/src/video/SDL_blit_N.c
	libs/cross/sdl/src/video/SDL_blit_A.c
	libs/cross/nosdl/nosdl.c 
	libs/cross/libgeotrans/src/albers.c 
	libs/cross/libgeotrans/src/azeq.c 
	libs/cross/libgeotrans/src/bng.c 
	libs/cross/libgeotrans/src/bonne.c 
	libs/cross/libgeotrans/src/cassini.c 
	libs/cross/libgeotrans/src/cyleqa.c 
	libs/cross/libgeotrans/src/eckert4.c 
	libs/cross/libgeotrans/src/eckert6.c 
	libs/cross/libgeotrans/src/eqdcyl.c 
	libs/cross/libgeotrans/src/gars.c 
	libs/cross/libgeotrans/src/geocent.c 
	libs/cross/libgeotrans/src/georef.c 
	libs/cross/libgeotrans/src/gnomonic.c 
	libs/cross/libgeotrans/src/grinten.c 
	libs/cross/libgeotrans/src/lambert_1.c 
	libs/cross/libgeotrans/src/lambert_2.c 
	libs/cross/libgeotrans/src/loccart.c 
	libs/cross/libgeotrans/src/mercator.c 
	libs/cross/libgeotrans/src/mgrs.c 
	libs/cross/libgeotrans/src/miller.c 
	libs/cross/libgeotrans/src/mollweid.c 
	libs/cross/libgeotrans/src/neys.c 
	libs/cross/libgeotrans/src/nzmg.c 
	libs/cross/libgeotrans/src/omerc.c 
	libs/cross/libgeotrans/src/orthogr.c 
	libs/cross/libgeotrans/src/polarst.c 
	libs/cross/libgeotrans/src/polycon.c 
	libs/cross/libgeotrans/src/sinusoid.c 
	libs/cross/libgeotrans/src/stereogr.c 
	libs/cross/libgeotrans/src/tranmerc.c 
	libs/cross/libgeotrans/src/trcyleqa.c 
	libs/cross/libgeotrans/src/ups.c 
	libs/cross/libgeotrans/src/usng.c 
	libs/cross/libgeotrans/src/utm.c 
	libs/cross/ezxml/ezxml.c 
	libs/cross/ul/ulClock.cpp 
	libs/cross/ul/ul.cpp 
	libs/cross/ul/ulError.cpp 
	libs/cross/ul/ulLinkedList.cpp 
	libs/cross/ul/ulList.cpp 
	libs/cross/ul/ulRTTI.cpp 
	libs/cross/sdlgfx/SDL_gfxBlitFunc.c 
	libs/cross/sdlgfx/SDL_gfxPrimitives.c 
	libs/cross/sdlgfx/SDL_imageFilter.c 
	libs/cross/sdlgfx/SDL_rotozoom.c
	core/file_collection.cpp 
	core/ozf_decoder.cpp 
	core/map_loader.cpp 
	core/map_projection.cpp 
	core/gauss.cpp 
	core/map_container.cpp 
	core/wpt_container.cpp 
	core/rte_container.cpp 
	core/map_index.cpp 
	core/map_filters.cpp 
	core/map_datums.cpp 
	core/map_render.cpp 
	core/qsort.cpp 
	core/log_stream.cpp
	libs/cross/zlib/adler32.c 
   	libs/cross/zlib/compress.c 
   	libs/cross/zlib/crc32.c 
   	libs/cross/zlib/deflate.c 
   	libs/cross/zlib/gzio.c 
   	libs/cross/zlib/infblock.c 
   	libs/cross/zlib/infcodes.c 
   	libs/cross/zlib/inffast.c 
   	libs/cross/zlib/inflate.c 
   	libs/cross/zlib/inftrees.c 
   	libs/cross/zlib/infutil.c 
   	libs/cross/zlib/trees.c 
   	libs/cross/zlib/uncompr.c 
   	libs/cross/zlib/zutil.c 
)


#target_link_libraries(${LIBRARY_NAME} ezxml
#                                      sdb
#                                      sdbwrap
#                                      freetype
#                                      utl
#                                      cardrender
#                                      convertutf
#                                      z
#                                      tremor
#                                      tljni
#                                      slowsound
#)

# SET(SOURCES jniwrappers.cpp)


set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-nostdlib -Wl,-shared,-Bsymbolic -Wl,-rpath-link=${PLATFORM_PATH}/arch-arm/usr/lib -Wl,--whole-archive -Wl,--no-undefined ${PLATFORM_PATH}/arch-arm/usr/lib/libc.so ${PLATFORM_PATH}/arch-arm/usr/lib/libstdc++.so ${PLATFORM_PATH}/arch-arm/usr/lib/libm.so ${PLATFORM_PATH}/arch-arm/usr/lib/liblog.so")

IF(UNIX)
  add_custom_command(TARGET ${LIBRARY_NAME} POST_BUILD
                     COMMAND  mkdir -p ../libs/armeabi)
  add_custom_command(TARGET ${LIBRARY_NAME} POST_BUILD
                     COMMAND  /bin/cp lib${LIBRARY_NAME}.so ../libs/armeabi)
ENDIF(UNIX)

